package com.ruoyi.jihuo.api.official;

import com.ruoyi.jihuo.api.ApiStrategy;
import com.ruoyi.jihuo.domain.JhTmAccount;
import com.taobao.top.BaseTopApiRequest;
import com.taobao.top.BaseTopApiResponse;
import com.taobao.top.TopApiClient;
import com.taobao.top.ability147.Ability147;
import com.taobao.top.ability147.request.TmallProductSchemaGetRequest;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class TmallProductSchemaGetStrategy implements ApiStrategy {
    @Override
    public BaseTopApiResponse execute(TopApiClient client, BaseTopApiRequest request, JhTmAccount jhTmAccount) throws IOException {
        Ability147 apiPackage = new Ability147(client);
        return apiPackage.tmallProductSchemaGet((TmallProductSchemaGetRequest) request, jhTmAccount.getJhAppSession());
    }

    @Override
    public BaseTopApiRequest setParams(String api, Map<String, Object> paramMap) {
        TmallProductSchemaGetRequest request = new TmallProductSchemaGetRequest();
        Long productId = (Long) paramMap.get("product_id");
        request.setProductId(productId);
        return request;
    }
}
